package com.kx.springmybatis.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName Order
 * @Author Sun
 * @Date 2021/5/17 20:06
 */
@Component //自动创建对象的注解, 会给对象默认分配一个 id, 当前类名的首字母小写
public class Order {
    @Value("1998/06/07")
    private Date date;
    //required代表是否必须,如果是必须的,在找不到对象的时候会抛出异常,如果不是必须的,则会继续下去不会抛出异常
    @Autowired(required = false) // 默认为true
    private Address address;

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "Order{" +
                "date=" + date +
                ", address=" + address +
                '}';
    }
}
